<template>
	<view class="parent-view">
		<scroll-view class="sgd-sc" scroll-y="true">
			<view class="sgd-sc-view">
				<swiper  class="sp-card-swiper" :indicator-dots="false"
				 :autoplay="true" :interval="5000" :circular="true":duration="300" :vertical="false">
					<swiper-item v-for="(item,index) in goodsData.baner_images" :key="index">
						<image class="sp-card-swiper-item" :src="item" :data-index="item" @click="bannerClick"/>
					</swiper-item>
				</swiper>
				
				<view class="card-info-view">
					<text class="goods-price">¥{{goodsData.price}}</text>
					<view class="goods-title" :style="goodsData.sub?'margin-bottom: 10px;':'margin-bottom: 20px;'">
						<text class="goods-tag">{{goodsData.label==='0'?'活动':'热卖'}}</text>
						<text class="goods-title-txt">{{goodsData.name}}</text>
					</view>
					<text class="good-desc" v-if="goodsData.sub">{{goodsData.sub}}</text>
				</view>
				
				<text class="goods-desc-txt">商品详情</text>
				
				<image class="good-detail-image" :src="goodsData.desc_image" :style="'height:'+goodsImageHeight+'px'"></image>
			</view>
		</scroll-view>
		<view class="bottom-pay-btn-view">
			<view class="btn-view">
				<image class="bottom-pay-btn-bg" src="http://c.shiqin.wang/photo/buy.png"></image>
				<text class="pay-price">应付金额：¥{{payPrice}}</text>
				<text class="pay-btn" @click="showBuyPop">立即购买</text>
			</view>
		</view>
		<goodsBuyPop :isShow="isShowGoodsBuyPop" :dataSource="goodsData"  @returnGoodsBuyPop="goodsBuyPopReturn"/>
	</view>
</template>

<script>
	import goodsBuyPop from "@/components/goods-buy-pop/goods-buy-pop.vue";
	import request from '../index/request.js';
	export default {
		components: {
			goodsBuyPop
		},
		data() {
			return {
				goodsData:{},
				goodsImageHeight:0,
				isShowGoodsBuyPop:false,
				payPrice:0.00
			}
		},
		methods: {
			onLoad: function(options) {
				var that=this
				this.appUtil.saveAppInviteId(options)
				this.goodsData=JSON.parse(decodeURIComponent(options.data))
				uni.getImageInfo({
					src:this.goodsData.desc_image,
					success(image) {
						console.log(JSON.stringify(image))
						that.goodsImageHeight=image.height*375/image.width
					},
					fail(error) {
						console.log(JSON.stringify(error))
					}
				})
			},
			onShow:function(){
				this.share.url='/pages/tabBar/home/index?appInviteId='+this.appUtil.getAppInviteId()
				this.share.shareType=1
			},
			
			getData:function(){
				request.post("api/user/login", {
				}).then(data => {
					
				})
			},
			showBuyPop:function(){
				this.isShowGoodsBuyPop=true
			},
			goodsBuyPopReturn:function(e){
				this.isShowGoodsBuyPop=e.isclose
				if(e.tag){
					var data=encodeURIComponent(JSON.stringify(e))
					uni.navigateTo({
						url:"../shopping-goods-buy-detail/index?fromData="+data
					})
				}
			},
		}
	}
</script>

<style>
	@import "index.css";
</style>
